<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      > 
      
     
    <ui:composition template="/template_notes.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle['Lists.List.Title']}"/>
        </ui:define>
        
        <ui:define name="menu">
            <div class="block_menu">
                <h:form>
                    <div class="block_menu_left">
                        <h:commandLink action="/index" value="#{bundle['Menu.Main']}"/>
                    </div>
                    <div class="block_menu_left">
                        <h:commandLink action="/notes/List" value="#{bundle['Menu.Notes']}"/>
                    </div>
                    
                    <div class="block_menu_right">
                        <h:commandLink action="#{userManagerController.logout()}" value="#{bundle['Menu.Logout']}"/>
                    </div>

                    <div class="block_menu_right">
                            <h:commandLink action="/profile/View" value="Hello #{userManagerController.getAuthenticatedUserName()}"/>
                    </div>                   
                    <h:panelGroup rendered="#{userManagerController.isRoleAdmin() == 1}">
                        <div class="block_menu_left">
                            <h:commandLink action="/users/List" value="#{bundle['Menu.UsersManagement']}"/>
                        </div>
                    </h:panelGroup>
                </h:form>
            </div>
        </ui:define>
        <ui:define name="line">
            <h:outputText value=""/>
        </ui:define>
       
        <!--  LEFT SIDE   -->
        <ui:define name="left">   
            <div class="block_list">
                

                <!-- ADD LIST -->
                <h:form>
                    <h:panelGrid columns="2" columnClasses="first_list,second_list" >

                        <h:inputText maxlength="15" id="name" required="true"
                            style="width: 190px; text-align: center; 
                            height: 30px; padding-left: 5px; font: 11pt 'Segoe WP'; font-size: 12pt; 
                            color: #707070; background-color: #ffffff; border: 2px solid #707070;"  
                            value="#{listController.name}" 
                            title="#{bundle['Lists.Add.Title.List']}"
                            requiredMessage="#{bundle['Lists.Add.RM.List']}"/>
 
                <h:commandButton type="submit" style="width: 75px; height: 36px; font: 12pt 'Segoe WP'; font-weight: bold;
                                         color: #505050; background-color: #f0f0f0; border: 3px solid #505050;" 
                                 value="#{bundle['Lists.Add.AddList']}"
                                 action="#{listController.create()}"/>
                    </h:panelGrid>
                </h:form>

                <!-- TABLE WITH LISTS -->
                <h:form>

                    <center>
                        <h:panelGroup rendered="#{listController.isListsExist() == 0}">
                            <br/>
                            <h:outputText escape="false" value="#{bundle['Lists.List.Empty']}" 
                                style="color: #505050; font-weight: bold; font: 14pt 'Segoe WP';"/>
                            <br/>
                            <h:outputText escape="false" value="#{bundle['Lists.List.AddNewList']}" 
                                style="color: #505050; font-weight: bold; font: 14pt 'Segoe WP';"/>
                        </h:panelGroup>

                    </center>

                    <h:panelGroup rendered="#{listController.isListsExist() == 1}">

                        <h:dataTable columnClasses="first,second,third"
                             width="98%" 
                           
                            value="#{listController.listsByUser}" 
                            var="item">
                            <h:column> 
                                <h:commandLink value="#{item.name}">
                                    <f:setPropertyActionListener 
                                        target="#{noteController.current_list_id}"
                                        value="#{item.id}"/>
                                </h:commandLink> 
                            </h:column>

                            <h:column>
                                <h:commandLink action="#{listController.edit}">
                                    <f:setPropertyActionListener 
                                        target="#{listController.current_list_id}" 
                                        value="#{item.id}"/>
                                    <h:graphicImage value="/images/edit_list.png"
                                            alt="#{bundle['Lists.List.EditLink']}"/>

                                </h:commandLink>

                            </h:column>
                            <h:column>

                                <h:commandLink action="#{listController.destroy}">
                                    <f:setPropertyActionListener 
                                        target="#{listController.current_list_id}"
                                        value="#{item.id}"/>
                                    <h:graphicImage value="/images/delete_list.png"
                                            alt="#{bundle['Lists.List.DestroyLink']}"/> 
                                </h:commandLink>
                            </h:column>
                        </h:dataTable>
                    </h:panelGroup>
                </h:form> 
            </div>
        </ui:define>
        

        
        <!--   CENTER SIDE     -->
        <ui:define name="body">
        <h:messages errorClass="error" infoClass="info" />

        <!-- ADD NOTES -->
        <h:panelGroup rendered="#{noteController.isSelectedList() == 1}">
            <h:form>
                <h:panelGrid columns="2" columnClasses="first_notes,second_notes" >
                    <h:inputText maxlength="45" id="name" required="true"
                        style="width: 85%; text-align: left;height: 30px; float: right; 
                        font: 11pt 'Segoe WP'; font-size: 12pt; color: #707070; padding-left: 20px; 
                        background-color: #ffffff; border: 2px solid #707070;"  
                        value="#{noteController.text}" 
                        title="#{bundle['Notes.Add.Title.Note']}"
                        requiredMessage="#{bundle['Notes.Add.RM.Note']}"/>
                    
                <h:commandButton type="submit" style="width: 100px; height: 36px; font: 12pt 'Segoe WP'; font-weight: bold;
                                         color: #505050; background-color: #f0f0f0; border: 3px solid #505050;" 
                                 value="#{bundle['Notes.Add.AddNote']}"
                                 action="#{noteController.addNote()}"/>
                
                </h:panelGrid>
            </h:form>
        </h:panelGroup>
        
        <center>
        <!-- TABLE WITH LIVE NOTES  -->  
        <f:view>
        <h:form>             

        <!--   ckecks if list is selected    -->
        <h:panelGroup rendered="#{noteController.isSelectedList() == 0}">
            <br/>
        <h:outputText escape="false" value="#{bundle['Notes.Note.SelectList']}"
                style="color: #808080; font-weight: bold; font: 24pt 'Segoe WP';"/>
        </h:panelGroup>

        <!--  ckecks if live notes exists    -->
        <h:panelGroup rendered="#{noteController.isNotesLiveExist() == 1}">
            
<!--            <h:outputText value="#{bundle['Notes.Title.LiveNotes']}"
                style="color: #707070;  font: 24pt 'Segoe WP'; font-weight: bold;"/>-->
            <h:dataTable columnClasses="first_column,second_column,
                    third_column,fourth_column,fifth_column,sixth_column" 
                    width="99%" rowClasses="table-row11,table-row22"
                    var="item" value="#{noteController.notesNoCompliteByList}" >
                    <h:column>
                        <!-- Mark note as completed    -->
                        <h:commandLink action="#{noteController.setCompleteTrue()}">
                            <f:setPropertyActionListener
                                target="#{noteController.current_note_id}"
                                value="#{item.id}"/>
                            <h:graphicImage value="/images/complite0.ico"
                              alt="#{bundle['Notes.List.Label.Completed']}"/>
                        </h:commandLink>
                    </h:column>

                    <h:column>                      
                        <h:panelGroup rendered="#{item.isPriority == 1}">
                            <!-- Mark note as not priority -->
                            <h:commandLink action="#{noteController.setPriorityFalse()}">
                                <f:setPropertyActionListener 
                                    target="#{noteController.current_note_id}"
                                    value="#{item.id}"/>
                                <h:graphicImage value="/images/priority1.ico" 
                                  alt="#{bundle['Notes.List.Title.Priority']}"/>
                            </h:commandLink>                
                        </h:panelGroup>
                        <h:panelGroup rendered="#{item.isPriority == 0}">
                            <!-- Mark note as priority -->
                            <h:commandLink action="#{noteController.setPriorityTrue()}">
                                <f:setPropertyActionListener 
                                    target="#{noteController.current_note_id}"
                                    value="#{item.id}"/>
                                <h:graphicImage style="padding-top: 6px;" 
                                  value="/images/priority_done0.png"
                                  alt="#{bundle['Notes.List.Title.Priority']}"/>
                            </h:commandLink>
                        </h:panelGroup>
                    </h:column>
                    <h:column>
                        <h:outputText style="color: black;" value="#{item.text}"/>
                    </h:column>
                
                
                
                
                    <h:column>
                        <h:panelGroup rendered="#{item.dateExpires != null}">
                            <h:outputText value="Expires"/>  <br/>            
                            <h:outputText value="#{item.dateExpires}">
                                <f:convertDateTime pattern="MM/dd/yyyy"/>
                            </h:outputText>
                        </h:panelGroup>
                    </h:column>
                
                
                
                
                    <h:column>
                        <h:commandLink action="#{noteController.editNoteDescription()}">
                            <f:setPropertyActionListener 
                                target="#{noteController.current_note_id}"
                                value="#{item.id}"/>
                            <h:graphicImage style="padding-top: 6px;" 
                                value="/images/edit.ico"/>
                        </h:commandLink>
                    </h:column>
                    <h:column>
                        <h:commandLink action="#{noteController.destroy}">
                            <f:setPropertyActionListener 
                              target="#{noteController.select_notes_for_delete}"
                                value="#{item.id}"/>   
                            <h:graphicImage value="/images/delete_notes.ico"
                                    alt="#{bundle['Notes.List.DeleteLink']}"/>
                        </h:commandLink>
                    </h:column>
                </h:dataTable>
            </h:panelGroup>
        </h:form>    
        </f:view>
            
            <br/>
            <br/>
            <br/>
            
        <!-- TABLE WITH COMPLETED NOTES  -->  
        <f:view>
        <h:form>
            <h:panelGroup rendered="#{noteController.isNotesCompletedExist() == 1}">
                <h:outputText style="color: #909090;  font: 20pt 'Segoe WP'; font-weight: bold;" 
                      value="#{bundle['Notes.Title.CompletedNotes']}"/>
                
            <h:dataTable columnClasses="first_column2,second_column2,
                    third_column2,fourth_column2,fifth_column2,sixth_column2" 
                    width="99%" rowClasses="table-row11,table-row22"
                    var="item" value="#{noteController.notesCompliteByList}" >
                    <h:column>
                        <!-- Mark note as not completed    -->
                        <h:commandLink action="#{noteController.setCompleteFalse()}">
                            <f:setPropertyActionListener
                                target="#{noteController.current_note_id}"
                                value="#{item.id}"/>
                            <h:graphicImage value="/images/complite1.ico"
                              alt="#{bundle['Notes.List.Label.Completed']}"/>
                        </h:commandLink> 
                    </h:column>
                    
                    <h:column>                      
                        <h:panelGroup rendered="#{item.isPriority == 1}">
                            <h:commandLink action="#{noteController.setPriorityFalse()}">
                                <f:setPropertyActionListener 
                                    target="#{noteController.current_note_id}"
                                    value="#{item.id}"/>
                                <h:graphicImage value="/images/priority_done1.png"
                                  alt="#{bundle['Notes.List.Title.Priority']}"/>
                            </h:commandLink>                
                        </h:panelGroup>
                        <h:panelGroup rendered="#{item.isPriority == 0}">
                            <h:commandLink action="#{noteController.setPriorityTrue()}">
                                <f:setPropertyActionListener 
                                    target="#{noteController.current_note_id}"
                                    value="#{item.id}"/>
                                <h:graphicImage value="/images/priority_done0.png"
                                  alt="#{bundle['Notes.List.Title.Priority']}"/>
                            </h:commandLink>
                        </h:panelGroup>
                    </h:column>
                    <h:column>
                        <h:outputText value="#{item.text}"/>
                    </h:column>
                    <h:column>
                        <h:commandLink action="#{noteController.destroy}">
                            <f:setPropertyActionListener 
                              target="#{noteController.select_notes_for_delete}"
                                value="#{item.id}"/>   
                            <h:graphicImage value="/images/delete_notes.ico"
                                    alt="#{bundle['Notes.List.DeleteLink']}"/>
                        </h:commandLink>
                    </h:column>
                </h:dataTable>
            </h:panelGroup>
        </h:form>    
        </f:view>
            
        </center>
        </ui:define>
    </ui:composition>

</html>